<%@ page import="cn.ixinjiu.libraryMangement.entity.BorrowInfo" %>
<%@ page import="cn.ixinjiu.libraryMangement.dao.impl.BorrowInfoDaoImpl" %>
<%@ page import="cn.ixinjiu.libraryMangement.dao.IBorrowInfoDao" %>
<%@ page import="java.io.PrintWriter" %>
<%@ page import="cn.ixinjiu.libraryMangement.dao.IBookInfoDao" %>
<%@ page import="cn.ixinjiu.libraryMangement.dao.impl.BookInfoDaoImpl" %>
<%@ page import="cn.ixinjiu.libraryMangement.entity.BookInfo" %>
<%@ page import="cn.ixinjiu.libraryMangement.service.IUserInfoService" %>
<%@ page import="cn.ixinjiu.libraryMangement.service.impl.UserInfoServiceImpl" %>
<%@ page import="cn.ixinjiu.libraryMangement.entity.UserInfo" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/5/20
  Time: 11:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>编辑信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
    <script src="/static/layui/layui.js" charset="utf-8"></script>
</head>
<body>
<%
    IUserInfoService userInfoService = new UserInfoServiceImpl();
    UserInfo userInfoById = userInfoService.getUserInfoById(Integer.parseInt(request.getParameter("id")));
%>


<form class="layui-form   layui-form-pane" action="">
    <%-- 隐藏id --%>
    <input type="id" name="id" value=<%=userInfoById.getId() %> class="layui-hide">
    <!-- 用户名 -->
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="user_name" value=<%=userInfoById.getUserName() %> required lay-verify="required"
                   placeholder="请输入用户名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <!-- 密码 -->
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="text" name="password" value=<%=userInfoById.getPassword() %> required lay-verify="required"
                   placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <!-- 邮箱 -->
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-block">
            <input type="text" name="email" value=<%=userInfoById.getEmail() %> required lay-verify="required"
                   placeholder="请输入邮箱" autocomplete="off" class="layui-input">
        </div>
    </div>
    <!-- 手机号 -->
    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-block">
            <input type="text" name="phone_number" value=<%=userInfoById.getPhoneNumber() %> required lay-verify="required"
                   placeholder="请输入手机号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <!-- 用户角色 -->
    <div class="layui-form-item">
        <label class="layui-form-label">用户角色</label>
        <div class="layui-input-block">
            <input type="text" name="role" value=<%=userInfoById.getRole() %> title="已归还"
                   lay-verify="required" placeholder="请输入用户角色" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>

</form>

<script>

    layui.use(['form', 'laydate'], function () {
        //layer.closeAll();
        $ = layui.jquery;
        var form = layui.form
        var laydate = layui.laydate; // 日期选择
        // 执行借书日期实例
        laydate.render({
            elem: '#publisher_at' //指定元素
        });
        //监听提交
        form.on('submit(formDemo)', function (data) {
            $.ajax({
                url: '/userInfoUpd',
                method: 'post',
                data: data.field, // JSON.stringify(data.field),
                dataType: 'json',
                success: function (data) {
                    if (data.code == "0") {
                        parent.layer.msg("修改成功", {
                            icon: 6,
                            time: 500
                        });
                        setTimeout(function () {
                            var index = parent.layer.getFrameIndex(window.name); // 操作父页面
                            parent.layer.close(index);
                        }, 500);

                    } else {
                        layer.msg("修改失败");
                    }
                }
            })
            return false;
        });
    });

</script>

</body>
</html>
